import openai, time
_api_key = "token1"
_api_base = "http://localhost:8080/v1"

openai.api_key  = _api_key
openai.api_base = _api_base
model_name = "yiyan"
start_time = time.time()

client = openai.OpenAI(api_key=_api_key, base_url=_api_base)


# send a ChatCompletion request to count to 100
response = client.chat.completions.create(
    model=model_name,
    messages=[
        {'role': 'user', 'content': '你好！'}
    ],
    temperature=0.1,
)

# calculate the time it took to receive the response
response_time = time.time() - start_time

# print the time delay and text received
print(f"Full response received {response_time:.2f} seconds after request")
print(f"Full response received:\n{response}")